package Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import Vo.Person;



public class PersonDao extends BaseDao {
	public Person find(String name){
		Connection con=this.getconnection();
		
		PreparedStatement ps= null;
		
		ResultSet rs=null;
		
		Person a=null;
		try {
			String sql="select * from person_information a where a.Pname=?";
			ps=con.prepareStatement(sql);
			ps.setString(1, name);
			rs=ps.executeQuery();
			if(rs.next()){
				System.out.println(rs.getString("Pname"));
			
			
				a=new Person();
				a.setName(rs.getString("Pname"));
				a.setAge(rs.getString("age"));
				a.setBirthday(rs.getDate("birthday"));
				a.setBirth_address(rs.getString("birthaddress"));
				a.setSex(rs.getString("sex"));
				a.setTelephone(rs.getString("telephone"));
				a.setOccupation(rs.getString("occupation"));
				a.setUnit(rs.getString("unit"));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			this.close(con, ps, rs);
		}
		return a;
	}
}
